home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Tools & Apps / Misc. Utilities / Installer 3.4 / Examples - Installer 3.4 / Action Atom Samples / Simple Action Atom Sample / ActionAtomSample.c next >
Encoding:
C/C++ Source or Header  |  1992-09-21  |  2.5 KB  |  85 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.2 sample: Action Atoms
  6.  *
  7.  *    File:        ActionAtomSample.c -    c Source
  8.  *
  9.  *    by:            Jon Zap
  10.  *  updated for use with Installer 3.4 by: Rich Kubota 9/8/92
  11.  *                rrk    - modified routines to return long values instead of Booleans
  12.  *
  13.  *    Copyright © 1990-1991 Apple Computer, Inc.
  14.  *    All rights reserved.
  15.  *
  16.  *----------------------------------------------------------------------------*/
  17. #if 0
  18. c -b ActionAtomSample.c
  19. Link -ra =resPurgeable -rt infn=1001 -rn -m ACTIONATOM -t rsrc -c RSED ∂
  20.         ActionAtomSample.c.o ∂
  21.         -o ActionAtomSample.rsrc
  22. #endif
  23.  
  24. #include <Traps.h>
  25. #include <Types.h>
  26. #include <QuickDraw.h>
  27. #include <Memory.h>
  28. #include <Files.h>
  29. #include <Resources.h>
  30. #include <Dialogs.h>
  31. #include <StandardFile.h>
  32. #include <ActionAtomIntf.h>
  33. #include "ActionAtomSelectors.h"
  34.  
  35. #define NIL 0
  36. #define CANCELERR    1
  37. #define ABORTERR    -1
  38.  
  39. long AlertAtom();
  40.  
  41. pascal long ACTIONATOM(AAPBRecPtr AB)
  42. {
  43.     switch (AB->aaRefCon) {    /* switch is useless here but we assume that we'll add other userFunctions */
  44.     
  45.     case ShowAlertSelector: 
  46.         return AlertAtom();
  47.     }
  48. }
  49.  
  50. long AlertAtom()
  51. {
  52.     unsigned short    screenWidth,screenHeight,alertWidth, alertHeight;
  53.     GrafPtr            myPort,thePort;
  54.     Rect            alertRect,t;
  55.     AlertTHndl        theAlert;
  56.     
  57.  
  58.     GetPort(&myPort);                                        // save Installer GrafPort
  59.     
  60.     theAlert = (AlertTHndl) GetResource('ALRT',128);        // get the alert template
  61.     HLock ((Handle)theAlert);                                // don't want to lose it
  62.     alertRect = *(Rect *)*theAlert;
  63.     alertWidth = alertRect.right - alertRect.left;                // calculate alert width
  64.     alertHeight = alertRect.bottom - alertRect.top;                // calculate alert height
  65.  
  66.     GetWMgrPort(&thePort);                                    // get desktop window port
  67.     t = thePort->portRect;
  68.     screenWidth = t.right - t.left;                                // calc screen width
  69.     screenHeight = t.bottom - t.top;                                // and height
  70.  
  71.     alertRect.left = t.left + ((screenWidth - alertWidth) >> 1);        // center alert on screen. calc new left.
  72.     alertRect.right = alertRect.left + alertWidth;                // calc new right
  73.     alertRect.top = 10 + t.top + ((screenHeight - alertHeight) >> 1);// calc new top
  74.     alertRect.bottom = alertRect.top + alertHeight;                // calc new bottom
  75.     *(Rect *)*theAlert = alertRect;
  76.  
  77.     (void) NoteAlert(128,NIL);                                // do alert
  78.     HUnlock ((Handle)theAlert);                                // free it up
  79.     DetachResource((Handle)theAlert);                        // don't re-write ALRT with new rectangle
  80.  
  81.     SetPort(myPort);                                        // give the port back
  82.     return noErr;
  83.         
  84. }
  85.